package org.springblade.modules.ad.entity;


import lombok.Data;
import lombok.ToString;
import org.springblade.modules.dingtalk.entity.DingTalkUser;

import java.io.UnsupportedEncodingException;
import java.util.LinkedList;


/**
 * AD 域用户
 * @ClassName AdUser.java
 * @version 1.0.0
 * @author zhangyunjiao
 * @createTime 2021/8/25
 */
@Data
@ToString
public class AdUser {

	/**
	 * 姓
	 */
	private String sn;

	/**
	 * 名
	 */
	private String givenName;


	/**
	 * 英文缩写
	 */
	private String initials;


	/**
	 * 显示名称
	 */
	private String displayName;


	/**
	 * 描述
	 */
	private String description;


	/**
	 *  办公室
	 */
	private String physicalDeliveryOfficeName;

	/**
	 * 电话号码
	 */
	private String telephoneNumber;


	/**
	 * 电话：其他
	 */
	private String otherTelephone;


	/**
	 * 电子邮件
	 */
	private String mail;



	/**
	 * 网页
	 */
	private String wwwHomePage;


	/**
	 * 网页：其他
	 */
	private String url;


	/**
	 * 用户登录名
	 */
	private String userPrincipalName;

	private String sAMAccountName;


	/**
	 * 登录时间
	 */
	private String logonHours;

	/**
	 * 登录到
	 */
	private String logonWorkstation;


	byte[] unicodePwd;
	/**
	 * 密码
	 */
	private String userPassword;

	public AdUser() {
	}

	public AdUser(DingTalkUser user) {
		this.givenName = user.getName();
		this.userPrincipalName = user.getName();
		this.sAMAccountName = user.getName();
		this.description = user.getName();
		this.telephoneNumber = user.getMobile();
		this.department = String.valueOf(user.getDeptIdList());
		this.userPassword = "12345.ssdLH";
		this.title = user.getTitle();
	}


	public byte[] setBytePwd(String password) {
		try {
			this.unicodePwd = ("\""+password+"\"").getBytes("UTF-16LE");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return unicodePwd;
	}

	/**
	 * 职务
	 */
	private String title;

	/**
	 * 部门
	 */
	private String department;

	/**
	 * 公司
	 */
	private String company;


	/**
	 * 经理
	 */
	private String manager;


	/**
	 * 用户控制
	 */
	private String userAccountControl;


	/**
	 * 通信地址
	 */
	private String postalAddress;

	/**
	 * ou 路径
	 */
	private LinkedList<String> basePath;

	private LinkedList<String> oldBasePath;

}
